import { Component, OnInit, Input } from '@angular/core';
import { ModalController } from '@ionic/angular';
import { ImgSlidePage } from '../slides-imgage/img-slide.page';

@Component({
  selector: 'app-companies-credential',
  templateUrl: './companies-credential.component.html',
  styleUrls: ['./companies-credential.component.scss'],
})
export class CompaniesCredentialComponent implements OnInit {
  // 组件数据
  @Input() tagData: any = {};
  // test: any = {
  //   "type": "tag",
  //   "style": "appImageTag",
  //   "name": null,
  //   "linearLayout": "body",
  //   "data": {
  //     "isExpand": "true",
  //     "watermarkImagUrl":
  //     "?x-oss-process=image/watermark,image_d2F0ZXJtYXJrMy5wbmc_eC1vc3MtcHJvY2Vzcz1pbWFnZS9yZXNpemUsUF8xMDA=,t_100,g_center,y_10,x_10",
  //     "watermarkLabel": "aaa",
  //     "images": [
  //       {
  //         "imgUrl": "http://oss-ppw.pupuwang.com/file_45527d821850fb05caa853890045e860.jpg"
  //       },
  //       {
  //         "imgUrl": "../../../assets/icon/examine_icon_phone@2x.png"
  //       }
  //     ]
  //   }
  // };

  constructor(private modalCtrl: ModalController) { }

  ngOnInit() {
    console.log(this.tagData);
  }

  // 图片放大
  async openImage_url(index, images, watermark) {
    const arr = [];
    if (watermark) {
      const key  = images + watermark;
      arr.push(key);
    } else {
      arr.push(images);
    }
    const value = { img: arr, index: index + 1 };
    console.log(value);
    const modal = await this.modalCtrl.create({
      component: ImgSlidePage,
      componentProps: { value: JSON.stringify(value) }
    });
    return await modal.present();
  }
}
